#include<bits/stdc++.h>
using namespace std;
int n,m,l,V,t;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        int sum=0,ans;
        cin>>n>>m>>l>>V;
        ans=m;
        long long a[100010],v[100010],d[100010],p[100010],c[100010];
        long long f[100010],fm[100010];
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            f[i]=0;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            fm[i]=0;
        }
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]>V&&d[i]<=p[m]){
                        sum++;
                    if(fm[m]==0)ans--;
                    fm[m]++;
                }
            }
            if(a[i]>0){
                long long x=d[i]*10000+((V*V-v[i]*v[i])/(2*a[i]))*10000;
                if(x<p[m]*10000){
                    sum++;
                    if(fm[m]==0)ans--;
                    fm[m]++;
                }
            }
            if(a[i]<0){
                int k=m;
                while(p[k]>=d[i]){
                    int s=p[k]-d[i];
                    double x=sqrt(100*v[i]*v[i]+2*a[i]*s*100)*1000;
                    if(x>V*10000){
                        sum++;
                        if(fm[k]==0)ans--;
                        fm[k]++;
                        break;
                    }
                    k--;
                }
            }

            //cout<<f[i]<<" "<<endl;
            //cout<<sum<<" "<<ans<<endl;
        }
        cout<<sum<<" "<<ans<<endl;
    }

    return 0;
}
